﻿#if FRAMEWORK_35

using System;
using System.Collections.Generic;
using System.Text;

using System.Xml;

using VisualEditor.Core;
using VisualEditor.Objects;
using System.Net;

namespace VisualEditor.IO
{
    public static class AthenaWriterExtender
    {
        public static void WriteToXML(this IDrawable drawable, XmlWriter oWriter)
        {
            oWriter.WriteStartElement("drawable");

            oWriter.WriteAttributeString("id", drawable.ID);
            oWriter.WriteAttributeString("label", drawable.Label);

            oWriter.WriteAttributeString("type", drawable.Type);

            //oWriter.WriteStartElement("boundingBox");
            WriteBoundingBox(oWriter, drawable);
            //oWriter.WriteEndElement(); // boundingBox

            oWriter.WriteAttributeString("startColor", Utility.ConvertColorToARGB(drawable.FillColorStart));
            oWriter.WriteAttributeString("endColor", Utility.ConvertColorToARGB(drawable.FillColorEnd));

            //oWriter.WriteStartElement("label");
            WriteLabel(oWriter, drawable);
            //oWriter.WriteEndElement(); // label

            oWriter.WriteAttributeString("respondsToCollission", drawable.RespondsToCollision.ToString());
            oWriter.WriteAttributeString("isVisible", drawable.IsVisible.ToString());
            oWriter.WriteAttributeString("viewType", drawable.View.ToString());

            oWriter.WriteEndElement(); // drawable

        }
        private static void WriteLabel(XmlWriter oWriter, IDrawable drawable)
        {
            oWriter.WriteAttributeString("showLabel", drawable.ShowLabel.ToString());
            oWriter.WriteAttributeString("labelColor", Utility.ConvertColorToARGB(drawable.LabelColor));
            oWriter.WriteAttributeString("font", drawable.LabelFont.Name);
            oWriter.WriteAttributeString("size", drawable.LabelFont.SizeInPoints.ToString());
            oWriter.WriteAttributeString("labelH", drawable.LabelH.ToString());
            oWriter.WriteAttributeString("labelV", drawable.LabelV.ToString());
        }
        private static void WriteBoundingBox(XmlWriter oWriter, IDrawable drawable)
        {
            oWriter.WriteAttributeString("x", drawable.Location.X.ToString());
            oWriter.WriteAttributeString("y", drawable.Location.Y.ToString());

            oWriter.WriteAttributeString("height", drawable.Dimensions.Height.ToString());
            oWriter.WriteAttributeString("width", drawable.Dimensions.Width.ToString());
        }
    }
}
#endif